﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;

public partial class Admin_PerInfo_View : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string userid = Session["UserId"].ToString();
        string username = "";
        string password = "";
        string usertype = "管理员";
        string name = "";
        string sex = "";
        string tel = "";
        string email = "";
        SqlConnection conn = new SqlConnection();
        conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringProManage"].ConnectionString;
        try
        {
            conn.Open();
            SqlCommand cmd = new SqlCommand();
            string SQL = "select uername,password,usertype,name,sex,tel,email from Users where (flag=1 and uername=@uername) ";
            cmd.Connection = conn;
            cmd.CommandText = SQL;
            cmd.CommandType = CommandType.Text;

            SqlParameter pusername = new SqlParameter("@uername", SqlDbType.VarChar, 10);
            pusername.Value = userid;
            cmd.Parameters.Add(pusername);
            //如果还有其他参数，一并添加
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())      //如果可以读（有数据），就开始读
            {
                username = reader["uername"].ToString();
                password = reader["password"].ToString();
                name = reader["name"].ToString();
                sex = reader["sex"].ToString();
                tel = reader["tel"].ToString();
                email = reader["email"].ToString();
            }
            Label1.Text = username;
            Label2.Text = password;
            Label3.Text = usertype;
            Label4.Text = name;
            Label5.Text = sex;
            Label6.Text = tel;
            Label7.Text = email;
        }
        finally
        {
            conn.Close();
        }
    }
}